import * as React from 'react'
import './index.less'

import NavHeader from '../../components/NavHeader'
import { Redirect } from 'react-router-dom'
interface Props {
  location:any,
  history:any

}
class Detail extends React.Component<Props> {
  render() {  
    // this.props.location.state从路由传过来的state值
    return this.props.location.state?( 
      <div className="lesson-detail">
        <NavHeader title="商品详情" history={this.props.history}/>
        <img src={this.props.location.state.poster}/>
        <p>{this.props.location.state.title}</p>
        <p>{this.props.location.state.price}</p>
      </div>
     ):<Redirect to="/"/>
  }
}
 
export default Detail